package com.app.TCES.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.app.TCES.domain.ST_indicators;
import com.app.TCES.domain.Student;
import com.app.TCES.domain.Test;
import com.app.TCES.service.StudentService;

@Controller
public class StudentController {

	Logger log = LogManager.getLogger(StudentController.class);
	
	@Autowired
	StudentService studentService;


	 
	// 学生修改密码
	@RequestMapping("/StuCGPW")
	@ResponseBody
	public Map<String, String> StuCGPW(Student student) {

		studentService.StuCGPW(student);

		Map<String, String> map = new HashMap<String, String>();
		map.put("msg", "成功");
		return map;

	}

	
	
	
	//获取学生评价问题内容
	@ResponseBody
	@RequestMapping("/selectStudentTest")
	public List<Test> selectStudentTest(){
		return studentService.selectStudentTest();
	}
	
	
	//学生给教师评分
	@ResponseBody
	@RequestMapping("/insertST")
	public Map<String, String> insertST(int tchId,double score,HttpServletRequest request){
		HttpSession httpSession=request.getSession();
        log.debug(httpSession.getAttribute("userId"));
        
        studentService.insertST(tchId,httpSession.getAttribute("userId") , score);
        
        Map<String, String> map = new HashMap<String, String>();
        map.put("msg", "YES");
        return map;
	}
	
	//通过学生查询是否已评价(stuId)
	@ResponseBody
	@RequestMapping("selectST")
	public List<ST_indicators> selectST(HttpServletRequest request){
		HttpSession httpSession=request.getSession();
		
		return studentService.selectST(httpSession.getAttribute("userId"));
	}
	
}
